package customerEnter.Frame.ServiceFram;

import java.lang.reflect.ParameterizedType;

import javax.annotation.Resource;

/**
 * 服務層接口框架實現
 * 
 * 类名称：ServerFramImpl 类描述： 创建人：dy 创建时间：2017-1-12 下午4:37:14
 * 
 */
public abstract class ServerFramImpl<T> implements ServerFramInterface {

	@Resource(name = "daoAutomaticFrameImpl")
	private DaoAutomaticFrameInterface	daoAutomaticFrameInterface;

	public Class<T>						class1;

	public Class<T>						cls;

	@SuppressWarnings("unchecked")
	public ServerFramImpl() {
		cls = (Class<T>) getBaseBens(class1);
	}

	@SuppressWarnings("unchecked")
	public T queryId(int id) {

		return daoAutomaticFrameInterface.queryId(id, cls);
	}

	private Class<?> getBaseBens(Class<?> classObject) {
		Class<?> ClassNew = null;
		if (classObject == null) {
			try {
				ClassNew = (Class<?>) Class.forName(((Class<?>) ((ParameterizedType) getClass().getGenericSuperclass())
						.getActualTypeArguments()[0]).getName());
			} catch (ClassNotFoundException e) {
				System.out.println("獲取泛型失敗");
			}
		}
		return ClassNew;
	}

}
